package top.techqi.base

import android.annotation.SuppressLint
import android.app.Application

@SuppressLint("PrivateApi")
@Suppress("unused")
object App {
    val INSTANCE: Application by lazy {
        try {
            return@lazy Class.forName("android.app.AppGlobals")
                .getMethod("getInitialApplication")
                .invoke(null) as Application
        } catch (ignored: Throwable) {
        }
        try {
            return@lazy Class.forName("android.app.ActivityThread")
                .getMethod("currentApplication")
                .invoke(null) as Application
        } catch (ignored: Throwable) {
        }
        throw KotlinReflectionNotSupportedError("No Application found.")
    }
}